Hello together, does anybody knows, if there exists a method to get the used icon of a listview item? When creating an item, using the insert function with icon parameter void insert(DBE listView, int row, string value, Icon icon) the specified icon will be added to the item. For the icon you can also use the getRealColorIcon(int realColorIndex) function (which also will be used in the AttrType dialog if specifying a color).
I've two listviews, each showing the content of one enumeration AttrType and I want to use the drag and drop functionality to "merge" both AttrTypes. Is there a possibility to get the inserted icon again? I can get the index of the dragged item as well as its (string) content, but not its icon.
Best regards,
Michael MichaelBrockhaus - Tue Aug 21 03:40:07 EDT 2018 |
Re: Get used icon from list view What you can do if there (as I suspect) is no built-in function you can make one, by hooking the insert function storing the Icons with the DBE. You could use the userdata field inside the listview to store the items (if you do not use it) or you can come up with your own indexing scheme. By hooking I mean something like:
void insertOld(DBE listView, int row, string value, Icon icon) {
insert(listView, row, value, icon);
}
void storeIcon(DBE listView, int row, Icon icon) {
// ... store the icon ...
}
// this is the newly implemented function
Icon getIcon(DBE listView, int index) {
// ... retrieve the item you stored
}
void insert(DBE listView, int row, string value, Icon icon) {
storeIcon(listView, row, icon);
insertOld(listView, row, value, icon);
}
The same way I did in the past with getting a title for a column inside a listview, etc.. Hope this helps ,regards, Mathias |
Re: Get used icon from list view Mathias Mamsch - Tue Aug 21 16:23:02 EDT 2018 What you can do if there (as I suspect) is no built-in function you can make one, by hooking the insert function storing the Icons with the DBE. You could use the userdata field inside the listview to store the items (if you do not use it) or you can come up with your own indexing scheme. By hooking I mean something like:
void insertOld(DBE listView, int row, string value, Icon icon) {
insert(listView, row, value, icon);
}
void storeIcon(DBE listView, int row, Icon icon) {
// ... store the icon ...
}
// this is the newly implemented function
Icon getIcon(DBE listView, int index) {
// ... retrieve the item you stored
}
void insert(DBE listView, int row, string value, Icon icon) {
storeIcon(listView, row, icon);
insertOld(listView, row, value, icon);
}
The same way I did in the past with getting a title for a column inside a listview, etc.. Hope this helps ,regards, Mathias Interesting idea... But I wonder why this can work? Does this functions not produce an infinite recursive call? insert(...) --> insertOld(...) --> insert(...) --> ... Now, I'm a little bit confused...
Further more... You talked about an "userdata field" within listviews? I know this concept vom MFC and .NET, but has DXL this feature, too? How can I get access to it? What data types can this field hold?
Thanks a lot and best regards, Michael |
Re: Get used icon from list view MichaelBrockhaus - Wed Aug 22 02:54:22 EDT 2018 Interesting idea... But I wonder why this can work? Does this functions not produce an infinite recursive call? insert(...) --> insertOld(...) --> insert(...) --> ... Now, I'm a little bit confused...
Further more... You talked about an "userdata field" within listviews? I know this concept vom MFC and .NET, but has DXL this feature, too? How can I get access to it? What data types can this field hold?
Thanks a lot and best regards, Michael This works because the DXL Parser will parse DXL top down in only one pass. That means it keeps a symbol / function table which whenever a reference to a variable or function turns up, it will look inside the table for the approprate symbol. That means if you declare a function you cannot call it above its declaration. But it also means that you can use this technique to hook any function. The user data field inside the listView you can read using this function: _x getClientData (DBE listView, int row) On the insert function you also have a variant where you can supply the client data: void insert (DBE listView, int row, string value, _x clientData, Icon index) As you can see the clientData can hold any data type, so if you do not use it, you can also put the Icon inside it. This way you get get the icon back using the getClientData function. In this case you get away with simply overriding the old insert function:
void insert(DBE listView, int row, string value, Icon icon) {
// call the variant with clientData!
// Note we pass icon twice!
insert(listView, row, value, icon, icon);
}
// this is the newly implemented function
Icon getIcon(DBE listView, int index) {
return (getClientData(listView,index)) Icon;
}
Hope that helps, regards, Mathias
|
Re: Get used icon from list view Mathias Mamsch - Wed Aug 22 04:50:54 EDT 2018 This works because the DXL Parser will parse DXL top down in only one pass. That means it keeps a symbol / function table which whenever a reference to a variable or function turns up, it will look inside the table for the approprate symbol. That means if you declare a function you cannot call it above its declaration. But it also means that you can use this technique to hook any function. The user data field inside the listView you can read using this function: _x getClientData (DBE listView, int row) On the insert function you also have a variant where you can supply the client data: void insert (DBE listView, int row, string value, _x clientData, Icon index) As you can see the clientData can hold any data type, so if you do not use it, you can also put the Icon inside it. This way you get get the icon back using the getClientData function. In this case you get away with simply overriding the old insert function:
void insert(DBE listView, int row, string value, Icon icon) {
// call the variant with clientData!
// Note we pass icon twice!
insert(listView, row, value, icon, icon);
}
// this is the newly implemented function
Icon getIcon(DBE listView, int index) {
return (getClientData(listView,index)) Icon;
}
Hope that helps, regards, Mathias
Thank you very much, Mathias. Your answer contained THREE new information for me: a) to handle any data type I can use "_x" as data type b) Parsing of DXL is an "one pass procedure" c) never heard about getClientData, before So, once again: Thank you very much. Best regards, Michael |